package components.plugins.album
{
	import UIFree.uif_component;
	
	import components.clt_component;
	
	import flash.events.Event;

	public class clt_albumRelease {
		private var _app: clt_clothingBase;
		private var _layer: clt_albumLayer;
		public function clt_albumRelease(a_clt: clt_clothingBase) {
			_app = a_clt;
		}
		
		public function execute(a_params: Object): void {
			appLayer.slideCenterToggle(false);
			if (!_layer) initLayer();
			_app.internalServer.getMyAlbum(doReseiveAlbum);
		}
		
		protected function get appLayer(): clt_component {
			return _app.layers[0] as clt_component;
		}
		
		private function doClose(e: Event): void {
			appLayer.slideCenterToggle(true);
			_layer.slideCenterToggle(false);
		}
		
		protected function initLayer(): void {
			_layer = new clt_albumLayer(_app.layers[1]);
			_layer.setVisibility(false);
			_layer.addEvent(Event.CLOSE, doClose);
		}
		
		private function doReseiveAlbum(a_data: Object): void {
			var list: Array = a_data.response[0] as Array;
			if (list && list.length) {
				_layer.assignList(list);
				_layer.slideCenterToggle(true);			
			}
		}
	}
}